package com.zhudi.model.enums;

public enum Identify {

    COMMON_USER(0,"普通用户",1),
    ADMIN(1,"管理员",2),
    SUPER_ADMIN(2,"超级管理员",3);


    ;


    /**
     * 对应数据库表中的身份/状态数字
     */
    private  int status;

    /**
     * 该数字对应的身份
     */
    private  String identity;

    /**
     * 该身份对应的权限等级
     */
    private  int permissionLevel;


    /**
     * 根据status找到对应的身份
     * @param status 状态
     * @return 对应的身份，没有则返回null
     */
    public static Identify getSatus(int status){
        //遍历枚举类来找到value对应的那个枚举
        for (Identify identify : Identify.values()) {
            if(identify.getStatus()==status){
                return identify;
            }

        }
        //如果找不到则返回空
        return null;
    }

    /**
     * 根据status找到对应的身份
     * @param identity 状态名称
     * @return 对应的身份，没有则返回null
     */
    public static Identify getSatus(String identity){
        //遍历枚举类来找到value对应的那个枚举
        for (Identify identify : Identify.values()) {
            if(identify.getIdentity().equals(identity)){
                return identify;
            }

        }
        //如果找不到则返回空
        return null;
    }

    Identify(int status, String identity, int permissionLevel) {
        this.status = status;
        this.identity = identity;
        this.permissionLevel = permissionLevel;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getIdentity() {
        return identity;
    }

    public void setIdentity(String identity) {
        this.identity = identity;
    }

    public int getPermissionLevel() {
        return permissionLevel;
    }

    public void setPermissionLevel(int permissionLevel) {
        this.permissionLevel = permissionLevel;
    }
}
